<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <titleAllocation Information Validate in Shared Area</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
		//分摊域分摊公共参数
		var areaResultUID = "<s:property value='areaResultUID' />";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>beshs/css/content.css" />
	<script type="text/javascript" src="<%=basePath%>resources/jquery/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>resources/datepicker/datepicker.js"></script>
	<!-- 页面特效 -->
	<jsp:include page="/beshs/res-refer/page-effect-reference.jsp" />
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
  </head>
  <script type="text/javascript">
 	 function shareAreaResultVerify() {
		var verifyResult = true;
		//热量表数据校验信息
		var heatMeterDataVerify = <s:property value='areaResultVerifyInfo.heatMeterDataVerify.success' />;
		//校验失败的热量表数据ID
		if(!heatMeterDataVerify) {
			verifyResult = false;
		}
		//分配表数据校验信息
		var assignMeterDataVerify = <s:property value='areaResultVerifyInfo.assignMeterDataVerify.success' />;
		if(!assignMeterDataVerify) {
			verifyResult = false;
		}
		//热用户校验信息
		var heatRoomVerify = <s:property value='areaResultVerifyInfo.heatRoomVerify.success' />;
		if(!heatRoomVerify) {
			verifyResult = false;
		}
		//分摊域校验信息
		var shareAreaVerify = <s:property value='areaResultVerifyInfo.shareAreaVerify.success' />;
		if(!shareAreaVerify) {
			verifyResult = false;
		}
		//分配表数据上传率校验信息
		var assignMeterUploadPerVerify = <s:property value='areaResultVerifyInfo.assignMeterUploadPerVerify.success' />;
		if(!assignMeterUploadPerVerify) {
			verifyResult = false;
		}
		return verifyResult;
	}
 	
 	function calcShareAreaResult() {
		if(shareAreaResultVerify()){
			Dialog.confirm("Are you sure to begin this allocation calculation?", function() {
	  			$.getJSON(path+"beshs/shareAreaResultActionJson!calcAreaResultByUID.do?date="+new Date(), {
	  				areaResultUID: areaResultUID
	  			}, function(data) {
	  				if(data.success) {
	  	  				Dialog.alert("Successful Operation！", function() {
	  	  				var index = parent.layer.getFrameIndex(window.name)
						parent.window.frames["c_content_content"].location = path + "beshs/shareAreaResultAction!queryAreaResultPage.do?date="+new Date();
	  	  				parent.layer.close(index);
	  	  				});
	  	  			} else {
	  	  				Dialog.alert(data.msg);
	  	  			}
	  			});
	  		});
		}else{
			Dialog.alert("Allocation calculation condition is not suffcient，please complete this data to submit！");
		}
  	}
 	
 	$(function() {
 		$("input[name='submit']").click(function() {
 			Dialog.alert("Allocation calculation need much time,please waiting for a while！");
 			calcShareAreaResult();
 		});
 		
 		$("input[name='cancel']").click(function() {
 			window.close();
 		});
 	});
  </script>
  <body>
    <div class="content_all">
  		<!--导航条-->
  		<div class="insertinfo_table">
      		<form action="#"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        		<tr>
          			<th>Shared Area：</th>
          			<td><s:property value='shareArea.areaName' />
            		<th>Allocation Name：</th>
          			<td><s:property value='shareAreaResult.shareName' /></td>
        		</tr>
        		<tr>
        			<th>Allocation Period Start Date</th>
        			<td>
        				<s:date name='shareAreaResult.startDate' format='yyyy-MM-dd' nice='false' />
        			</td>
        			<th>Allocation Period End Date</th>
        			<td>
        				<s:date name='shareAreaResult.endDate' format='yyyy-MM-dd' nice='false' />
        			</td>
        		</tr>
        		<tr>
        			<th>Allocation Method</th>
        			<td>
        				<s:if test="shareAreaResult.shareType==1">Process Allocation</s:if>
        				<s:if test="shareAreaResult.shareType==2">Charge Allocation</s:if>
        			</td>
        			<th></th>
        			<td></td>
        		</tr>
        		<tr>
        			<th>1.Shared Area Information</th>
        			<td colspan="3" style="white-space: normal;">
		          		<s:if test="areaResultVerifyInfo.shareAreaVerify.success">
		          			<span>
		          				<s:property value="areaResultVerifyInfo.shareAreaVerify.msg"/>
		          			</span>
		          		</s:if>
		          		<s:else>
		          			<span style="color:FF0000;">
		          				<s:property value="areaResultVerifyInfo.shareAreaVerify.msg"/>
		          			</span>
		          		</s:else>
		          	</td>
        		</tr>
        		<tr>
        			<th>2.Heat User Information</th>
        			<td colspan="3" style="white-space: normal;">
        				<s:if test="areaResultVerifyInfo.heatRoomVerify.success">
		          			<span>
		          				<s:property value="areaResultVerifyInfo.heatRoomVerify.msg"/>
		          			</span>
		          		</s:if>
		          		<script type="text/javascript">
		          			/** 更正校验失败的热用户信息 **/
		          			function correctRoomInfo() {
		          				var illegalVerifyInfo = "<s:property escape='false' value='areaResultVerifyInfo.heatRoomVerify.msg'/>";
		          				var illegalIDList = "<s:property value='areaResultVerifyInfo.heatRoomIDList'/>";
		          				Dialog.confirm("Begin to correct the invalidate information！", function() {
		          					var pwin = window.dialogArguments;
		          	  				pwin.parent.window.frames["c_content_content"].location = path + "beshs/shareAreaResultAction!areaResultInfoCorrectMgr.do?areaResultUID="+areaResultUID
		          	  						+"&illegalVerifyInfo="+encodeURIComponent(illegalVerifyInfo)
		          	  						+"&infoSort=heatRoom"
		          	  						+"&illegalIDList="+illegalIDList
		          	  						+"&date="+new Date();
		          	  				window.close();
		          				});
		          			}
		          		</script>
		          		<s:else>
		          			<span style="color:FF0000;">
		          				<a href="javascript:correctRoomInfo();">
		          					<s:property value="areaResultVerifyInfo.heatRoomVerify.msg"/>
		          				</a>
		          			</span>
		          		</s:else>
					</td>
        		</tr>
        		<tr>
        			<th>3.Heat meter data</th>
        			<td colspan="3" style="white-space: normal;">
        				<s:if test="areaResultVerifyInfo.heatMeterDataVerify.success">
		          			<span>
		          				<s:property value="areaResultVerifyInfo.heatMeterDataVerify.msg"/>
		          			</span>
		          		</s:if>
		          		<script type="text/javascript">
		          			/** 更正校验失败的热量表数据信息 **/
		          			function correctHeatMeterInfo() {
		          				var illegalVerifyInfo = "<s:property escape='false' value='areaResultVerifyInfo.heatMeterDataVerify.msg'/>";
		          				var illegalIDList = "<s:property value='areaResultVerifyInfo.heatMeterDataIDList'/>";
		          				var meterNoList = "<s:property value='areaResultVerifyInfo.meterNoList'/>";
		          				Dialog.confirm("Begin to correct the invalidate information！", function() {
		          					var pwin = window.dialogArguments;
		          	  				pwin.parent.window.frames["c_content_content"].location = path + "beshs/shareAreaResultAction!areaResultInfoCorrectMgr.do?areaResultUID="+areaResultUID
		          	  						+"&illegalVerifyInfo="+encodeURIComponent(illegalVerifyInfo)
		          	  						+"&infoSort=heatMeterData"
		          	  						+"&illegalIDList="+illegalIDList
		          	  						+"&meterNoList="+meterNoList
		          	  						+"&date="+new Date();
		          	  				window.close();
		          				});
		          			}
		          		</script>
		          		<s:else>
		          			<span style="color:FF0000;">
		          				<a href="javascript:correctHeatMeterInfo();">
		          					<s:property value="areaResultVerifyInfo.heatMeterDataVerify.msg"/>
		          				</a>
		          			</span>
		          		</s:else>
        			</td>
        		</tr>
        		<tr>
        			<th>4.Allocator Data</th>
        			<td colspan="3" style="white-space: normal;">
        				<s:if test="areaResultVerifyInfo.assignMeterDataVerify.success && 
        						areaResultVerifyInfo.assignMeterUploadPerVerify.success">
		          			<span>
		          				<s:property value="areaResultVerifyInfo.assignMeterDataVerify.msg"/>
		          				<s:property value="areaResultVerifyInfo.assignMeterUploadPerVerify.msg"/>
		          			</span>
		          		</s:if>
		          		<script type="text/javascript">
		          			/** 更正校验失败的分配表数据信息 **/
		          			function correctAssignMeterInfo() {
		          				var illegalVerifyInfo = "<s:property escape='false' value='areaResultVerifyInfo.assignMeterDataVerify.msg'/>";
		          				illegalVerifyInfo += "<s:property escape='false' value='areaResultVerifyInfo.assignMeterUploadPerVerify.msg'/>";
		          				var illegalIDList = "<s:property value='areaResultVerifyInfo.assignMeterDataIDList'/>";
		          				var roomOwnerList = "<s:property escape='false' value='areaResultVerifyInfo.roomOwnerList'/>";
		          				var seriousNumList = "<s:property value='areaResultVerifyInfo.seriousNumList'/>";
		          				Dialog.confirm("Begin to correct the invalidate information！", function() {
		          					var pwin = window.dialogArguments;
		          	  				pwin.parent.window.frames["c_content_content"].location = path + "beshs/shareAreaResultAction!areaResultInfoCorrectMgr.do?areaResultUID="+areaResultUID
		          	  						+"&illegalVerifyInfo="+encodeURIComponent(illegalVerifyInfo)
		          	  						+"&infoSort=assignMeterData"
		          	  						+"&illegalIDList="+illegalIDList
		          	  						+"&roomOwnerList="+encodeURIComponent(roomOwnerList)
		          	  						+"&seriousNumList="+seriousNumList
		          	  						+"&date="+new Date();
		          	  				window.close();
		          				});
		          			}
		          		</script>
		          		<s:else>
		          			<s:if test="areaResultVerifyInfo.assignMeterDataVerify.success">
		          				<span>
			          				<s:property value="areaResultVerifyInfo.assignMeterDataVerify.msg"/>
			          			</span>
		          			</s:if>
		          			<s:else>
		          				<span style="color:FF0000;">
		          					<a href="javascript:correctAssignMeterInfo();">
		          						<s:property value="areaResultVerifyInfo.assignMeterDataVerify.msg"/>
		          					</a>
		          				</span>
		          			</s:else>
		          			<s:if test="areaResultVerifyInfo.assignMeterUploadPerVerify.success">
		          				<span>
			          				<s:property value="areaResultVerifyInfo.assignMeterUploadPerVerify.msg"/>
			          			</span>
		          			</s:if>
		          			<s:else>
		          				<span style="color:FF0000;">
		          					<a href="javascript:correctAssignMeterInfo();">
		          						<s:property value="areaResultVerifyInfo.assignMeterUploadPerVerify.msg"/>
		          					</a>
		          				</span>
		          			</s:else>
		          		</s:else>
		          	</td>
        		</tr>
        		<tr>
          			<td style="border:none" colspan="4" align="center">
          				<input name="submit" type="button" value="Allocation" class="s_btn"/>
            			<input name="cancel" type="button" value="Cancel" class="s_btn"/></td>
        		</tr>
      		</table></form>
  		</div>
	</div>
	<div class="clear"></div>
  </body>
</html>
